var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function s() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (s.prototype = t.prototype, 
    new s());
}), a = this && this.__decorate || function(e, t, o, s) {
    var l, c = arguments.length, n = c < 3 ? t : null === s ? s = Object.getOwnPropertyDescriptor(t, o) : s;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(e, t, o, s); else for (var a = e.length - 1; 0 <= a; a--) (l = e[a]) && (n = (c < 3 ? l(n) : 3 < c ? l(t, o, n) : l(t, o)) || n);
    return 3 < c && n && Object.defineProperty(t, o, n), n;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("PrefabView"), s = e("Global"), c = e("AudioManager"), l = e("GameConfig"), d = e("GameData"), u = e("DataManager"), p = e("LoadManager"), h = e("UIManager"), f = e("DrawManager"), g = e("WebManager"), m = cc._decorator, y = m.ccclass, v = m.property, w = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.titleSprite = null, e.btnSprite = null, e.tag = "desktop", e;
    }
    return i(e, t), e.prototype.onLoad = function() {
        this.tag = PD.tag, "desktop" == this.tag ? (p.default.getInstance().loadSpriteFrame({
            url: "image/ui/添加有礼@2x",
            sprite: this.titleSprite
        }), p.default.getInstance().loadSpriteFrame({
            url: "image/ui/添加领取@2x",
            sprite: this.btnSprite
        })) : "follow" == this.tag && (p.default.getInstance().loadSpriteFrame({
            url: "image/ui/关注有礼@2x",
            sprite: this.titleSprite
        }), p.default.getInstance().loadSpriteFrame({
            url: "image/ui/关注领取@2x",
            sprite: this.btnSprite
        }));
    }, e.prototype.onDestroy = function() {
        t.prototype.onDestroy.call(this), h.default.getInstance().showPnl("start");
    }, e.prototype.onClickClose = function() {
        c.default.getInstance().playAudio("按钮2"), "desktop" == this.tag ? g.default.getInstance().sentLog("点击添加有礼返回按键") : "follow" == this.tag && g.default.getInstance().sentLog("点击关注有礼返回按键"), 
        h.default.getInstance().hideAllPnl();
    }, e.prototype.onClick = function() {
        var e = this;
        c.default.getInstance().playAudio("按钮2"), GA.Info.underCheck && l.GC.isDebug ? (h.default.getInstance().loadPopPnl("draw_reward", f.default.getInstance().doDraw()), 
        h.default.getInstance().hideAllPnl()) : "desktop" == this.tag ? GA.isPlatform(GA.Platform.ByteDance) && GA.PA && GA.PA.addShortcut({
            success: function(e) {
                console.log("addShortcut success", e), GA.PA.checkShortcut({
                    success: function(e) {
                        console.log("checkShortcut success", e), s.G.isExist = e.status.exist, s.G.isExist && (g.default.getInstance().sentLog("添加有礼成功"), 
                        h.default.getInstance().loadPopPnl("draw_reward", f.default.getInstance().doDraw()), 
                        h.default.getInstance().hideAllPnl(), d.GD.isAddToDesktop = 1, u.default.getInstance().save());
                    },
                    fail: function(e) {
                        console.log("checkShortcut fail", e);
                    }
                });
            },
            fail: function(e) {
                console.log("addShortcut fail", e);
            }
        }) : "follow" == this.tag && this.openAwemeUserProfile({
            success: function() {
                e.checkFollowAwemeState({
                    success: function() {
                        s.G.isFollow && (g.default.getInstance().sentLog("关注有礼成功"), h.default.getInstance().loadPopPnl("draw_reward", f.default.getInstance().doDraw()), 
                        h.default.getInstance().hideAllPnl(), d.GD.isFollow = 1, u.default.getInstance().save());
                    }
                });
            }
        });
    }, e.prototype.checkFollowAwemeState = function(t) {
        GA.isPlatform(GA.Platform.ByteDance) ? GA.PA && GA.PA.checkFollowAwemeState({
            success: function(e) {
                console.log("checkFollowAwemeState success", e), e.hasFollowed ? s.G.isFollow = !0 : s.G.isFollow = !1, 
                t.success && t.success(e);
            },
            fail: function(e) {
                console.log("checkFollowAwemeState fail", e);
            }
        }) : GA.isPlatform(GA.Platform.Kwaigame) && ks && ks.checkFollowState({
            accountType: "CPServiceAccount",
            callback: function(e) {
                1 == e.errorCode ? (console.log("checkFollowState success", e), e.hasFollow ? s.G.isFollow = !0 : s.G.isFollow = !1, 
                t.success && t.success(e)) : console.log("checkFollowState fail", e);
            }
        });
    }, e.prototype.openAwemeUserProfile = function(t) {
        GA.isPlatform(GA.Platform.ByteDance) ? GA.PA && GA.PA.openAwemeUserProfile({
            success: function(e) {
                console.log("openAwemeUserProfile success", e), t.success && t.success(e);
            },
            fail: function(e) {
                console.log("openAwemeUserProfile fail", e);
            }
        }) : GA.isPlatform(GA.Platform.Kwaigame) && ks && ks.openUserProfile({
            accountType: "CPServiceAccount",
            callback: function(e) {
                1 == e.errorCode ? (console.log("openUserProfile success", e), t.success && t.success(e)) : console.log("openUserProfile fail", e);
            }
        });
    }, a([ v(cc.Sprite) ], e.prototype, "titleSprite", void 0), a([ v(cc.Sprite) ], e.prototype, "btnSprite", void 0), 
    a([ y ], e);
}(r.default);

n.default = w;